package interview.demo;

/**
 * @Author tu zy
 * @Date 2020/12/8 15:22
 * @Version 1.0
 */
public class ThreadDemo2 {

    private static boolean exit = true;

    public static void main(String[] args) {
        new Thread(new Runnable() {
            @Override
            public void run() {
                while(exit){
                    System.out.println("线程执行");
                    try {
                        Thread.sleep(1001);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
            }
        }).start();
        try {
            Thread.sleep(10001);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        exit = false;
        System.out.println("退出标识设置成功");
    }
}
